<template>
	<div>
		<h3>员工登录</h3>
		<van-form @submit="onSubmit">
		  <van-field v-model="username" name="用户名" label="用户名" placeholder="用户名" :rules="[{ required: true, message: '请填写用户名' }]"
		  />
		  <van-field  v-model="password"  type="password" name="密码" label="密码" placeholder="密码" :rules="[{ required: true, message: '请填写密码' }]"
		  />
		  <div style="margin: 16px;">
		      <van-button round block type="info" native-type="submit">
		        提交
		      </van-button>
		    </div>
		  </van-form>
	</div>
</template>

<script>
export default {
  name: 'HelloWorld',
  data(){
  	  return{
  		  show: true,
		  username: '',
		  password: '',
  	  }
  },
  methods: {
      onSubmit() {
       var username = this.username
	   var password = this.password
	   this.$axios.get(`${this.$httpurl}/admin?username=${username}&password=${password}`).then((response)=>{
		  if(response.data.length){
			  this.$toast.success(`用户${username}登录成功！`)
			  this.$toast.setDefaultOptions({ duration: 1000 });
			  window.location.href=`${this.$locationurl}/#/about`
		  }
		  else{
			  this.$toast.fail(`登录失败，请重新输入！`)
		  }
	   })
      }
    },
  mounted() {
  	
  },
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less">



</style>
